<html>
	<head>
		<title>工厂模式</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<script>
			var BicycleShop = function() {
			}

			BicycleShop.prototype = {
				sellBicycle : function(model) {
					var bicycle = this.createBicycle(model);
					return bicycle;
				},
				createBicycle : function(model) {
					throw new Error(" Unsupported ");
				}
			}
			/*=================
			 *延迟至子类定义
			 =================*/
			var AcmeBicycleShop = function() {
			};
			//工厂1

			extend(AcmeBicycleShop, BicycleShop);
			AcmeBicycleShop.prototype.createBicycle = function(model) {
				var bicycle;
				switch( model ) {
					case "The Speedster":
						bicycle = new AcmeSpeedster();
						break;
					case "The Lowrider":
						bicycle = new AcmeLowrider();
						break;
					case "The Cruiser":
					default:
						bicycle = new AcmeCruiser();
						break;
				}
				return bicycle;
			}
			var GeneralBicycleShop = function() {
			};
			//工厂2
			extend(GeneralBicycleShop, BicycleShop);
			GeneralBicycleShop.prototype.createBicycle = function(model) {

			}
			//声明
			var acmeShop = new AcmeBicycleShop();
			var newBicycle = acmeShop.sellBicycle("The Speedster");
		</script>
	</head>
	<body></body>
</html>